package com.kylin.common.core.mapper;

import com.kylin.common.core.mybatis.mapper.probider.TreeSqlProvider;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import java.io.Serializable;

/**
 * 通用树相关数据接口
 *
 * @author wuhao
 * @version 1.0 - 2019-02-25
 */
public interface TreeMapper<T> extends DataMapper<T> {

    /**
     * 更新子节点信息
     * @param oldEntity 旧对象
     * @param newEntity 新对象
     * @return  
     * @author wuhao
     * @since 2.6.0 - 2022/6/26
     */
    @UpdateProvider(type = TreeSqlProvider.class, method = "updateChild")
    Integer updateChild(T oldEntity, T newEntity);

    /**
     * 根据id获取父节点信息
     * @param entity 对象
     * @param id 主键id
     * @return
     * @author wuhao
     * @since 2.6.0 - 2023/1/2
     */
    @SelectProvider(type = TreeSqlProvider.class, method = "getParentById")
    T getParentById(T entity, Serializable id) ;
}
